class Controller {
  sum() {
    console.log(this == hd)
    return this.data.reduce((t,l)=> t+=l.price,0)
  }
}

class Lesson extends Controller { 
  constructor(lessons) {
    super();
    this.data = lessons;
  }

  info() {
    console.log(this.sum == super.sum)
    console.log(this.sum, super.sum)
    // 子类重写父类方法时， super能够发挥重要作用
    return {
      totalPrice: super.sum(),
      data: this.data
    };
  }
}

let data = [
  { name: "js", price: 100 },
  { name: "mysql", price: 212 },
  { name: "vue.js", price: 98 }
];
const hd = new Lesson(data);
console.log(hd.info());